<#assign ctx=request.contextPath/>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<link rel="stylesheet" href="${ctx}/css/common.css" />
		<link rel="stylesheet" href="${ctx}/css/login.css" />
	</head>
	<body>
		<div class="middle">
			<a href="index.html"><img src="${ctx}/img/logo.jpg" alt="logo" /></a>
			<form id="login" onsubmit="return false">
			<font color="red"><a>${tip!''}</a></font><br/>
				<label for="name">登录名</label><input type="text" name="user_id" id="name" />
				<div id="nametip">*请输入6-16位的用户名!</div>
				<div id="nametip1">*该用户还未注册 ，请先注册！</div>
				<div id="nametip2">*不允许有空格！</div>
				<br />
				<label for="pwd">密码</label><input type="password" name="pass_word" id="pwd" />
				<span class="square"></span>
				<span class="forget_pwd"><a href="javascript:void(0)">忘记密码</a></span>
				<div id="pwdtip">*请输入6-18位的密码！</div>
				<div id="pwdtip1">*密码错误！</div>
				<br />
				<label>验证码</label>
				<input type="text" name="code" id="code" />
				<span class="vertification_code">
				<img id="vimg" src="${ctx}/CheckController" style="width: 100px;height: 50px;"></span>
				<span class="change_img"><a id="kanbuq" href="javascript:;">看不清，换一张</a></span>
				<div id="codetip">*验证码有误</div>
				<br />
				<input type="submit" id="sub" name="sub" value="登录" onclick="subInput()">
				<span class="registic"><a href="${ctx}/reg.html">免费注册</a></span>
			</form>
		</div>
		
		<!--尾部-->
		<#include "common/bottom.html">
		<script type="text/javascript" src="${ctx}/static/lib/jquery/1.9.1/jquery.min.js"></script> 
		<script type="text/javascript" src="${ctx}/static/h-ui/js/H-ui.js"></script> 
		<script type="text/javascript">
			$(function(){
				$("#vimg").click(function(){
					var num = Math.random();
					console.log("num:"+num);
					$(this).attr("src","${ctx}/CheckController?"+num);
				});
				
				$("#sub").click(function(){
					alert("----")
					var tip = "";
					var username= $("#name").val();
					var password = $("#pwd").val();
					var code = $("#code").val();
					if($.trim(username) == ""){
						tip="用户名不能为空";
						$("#username").focus();
					}else if($.trim(password) == ""){
						tip="密码不能为空";
						$("#password").focus();
					}else if($.trim(code) == ""){
						tip="验证码不能为空";
						$("#code").focus();
					}
					if(tip == ""){
						//验证通过,发送ajax请求
						$.post("${ctx}/customer/customerLogin", 
							{ user_id: username, pass_word: password, code: code },
							  function(data){					   
								if(data.status == "success"){
									location.href = "${ctx}/customer/home";
								}else{
									$("#vimg").trigger("click");
									alert(data.tip);
								}
					
							 });

					}else{
						alert(tip);	
					}
					
					
				});
				});
		</script>

	</body>

</html>